package com.ctl.utils.swing;


/**
 * <p>Title: Point</p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2019</p>
 * <p>Company: www.ctl.com</p>
 *
 * @author ctl
 * @version 1.1
 * @date 2022-12-19 11:49
 */
public class Point implements Comparable<Point> {
    private Double x;
    private Double y;

    @Override
    public String toString() {
        return "Point{" +
                "x=" + x +
                ", y=" + y +
                '}';
    }
    @Override
    public int compareTo(Point o) {
        if (this.x == null || this.y == null || o.x == null || o.y == null) {
            return 0;
        }
        if (this.x > o.x) {
            return 1;
        } else if (this.x <= o.x) {
            return -1;
        } else if (this.x.equals(o.x)) {
            if (this.y > o.y) {
                return 1;
            } else if (this.y <= o.y) {
                return -1;
            } else if (this.y.equals(o.y)) {
                return 0;
            }
        }
        return 0;
    }

    public Point withX(double x) {
        this.x = x;
        return this;
    }

    public Point withY(double y) {
        this.y = y;
        return this;
    }


    public Double getX() {
        return x;
    }

    public void setX(Double x) {
        this.x = x;
    }

    public Double getY() {
        return y;
    }

    public void setY(Double y) {
        this.y = y;
    }
}
